<template>
	<view class="invoice-detail">
		<view class="detail-list" v-if="invoiceDetail !== ''">
			<view class="detail-list-item flex-center-between">
				<view class="detail-list-item-name">发票对象</view>
				<view class="detail-list-item-txt">
					{{invoiceDetail.invoice_object == 1 ? '个人' : invoiceDetail.invoice_object == 2 ? '企业' : ''}}
				</view>
			</view>
			<view class="detail-list-item flex-center-between">
				<view class="detail-list-item-name">发票类型</view>
				<view class="detail-list-item-txt">
					{{invoiceDetail.invoice_type == 1 ? '电子' : invoiceDetail.invoice_type == 2 ? '纸质':''}}
				</view>
			</view>
			<view v-if="invoiceDetail.invoice_object === 1">
				<view class="detail-list-item flex-center-between">
					<view class="detail-list-item-name">增值税发票</view>
					<view class="detail-list-item-txt">
						{{invoiceDetail.personal.vatt == 1 ? '是' : '否'}}
					</view>
				</view>
				<view class="detail-list-item flex-center-between">
					<view class="detail-list-item-name">联系人</view>
					<view class="detail-list-item-txt">
						{{invoiceDetail.personal.contact}}
					</view>
				</view>
				<view class="detail-list-item flex-center-between">
					<view class="detail-list-item-name">手机号</view>
					<view class="detail-list-item-txt">
						{{invoiceDetail.personal.phone}}
					</view>
				</view>
				<view v-if="invoiceDetail.invoice_type === 1" class="detail-list-item flex-center-between">
					<view class="detail-list-item-name">邮箱</view>
					<view class="detail-list-item-txt">
						{{invoiceDetail.personal.email}}
					</view>
				</view>
				<view v-if="invoiceDetail.invoice_type === 2" class="detail-list-item flex-center-between">
					<view class="detail-list-item-name">地址</view>
					<view class="detail-list-item-txt">
						{{invoiceDetail.personal.address}}
					</view>
				</view>
			</view>
			<view v-if="invoiceDetail.invoice_object == 2">
				<view class="detail-list-item flex-center-between">
					<view class="detail-list-item-name">增值税发票</view>
					<view class="detail-list-item-txt">
						{{invoiceDetail.enterprise.vatt == 1 ? '是' : '否'}}
					</view>
				</view>
				<view class="detail-list-item flex-center-between">
					<view class="detail-list-item-name">抬头</view>
					<view class="detail-list-item-txt">
						{{invoiceDetail.enterprise.title}}
					</view>
				</view>
				<view class="detail-list-item flex-center-between">
					<view class="detail-list-item-name">联系人</view>
					<view class="detail-list-item-txt">
						{{invoiceDetail.enterprise.contact}}
					</view>
				</view>
				<view class="detail-list-item flex-center-between">
					<view class="detail-list-item-name">手机号</view>
					<view class="detail-list-item-txt">
						{{invoiceDetail.enterprise.phone}}
					</view>
				</view>
				<view class="detail-list-item flex-center-between">
					<view class="detail-list-item-name">银行账号</view>
					<view class="detail-list-item-txt">
						{{invoiceDetail.enterprise.bank_num}}
					</view>
				</view>
				<view class="detail-list-item flex-center-between">
					<view class="detail-list-item-name">开户银行</view>
					<view class="detail-list-item-txt">
						{{invoiceDetail.enterprise.bank}}
					</view>
				</view>
				<view class="detail-list-item flex-center-between">
					<view class="detail-list-item-name">税号</view>
					<view class="detail-list-item-txt">
						{{invoiceDetail.enterprise.tax_number}}
					</view>
				</view>
				<view v-if="invoiceDetail.invoice_type === 1" class="detail-list-item flex-center-between">
					<view class="detail-list-item-name">邮箱</view>
					<view class="detail-list-item-txt">
						{{invoiceDetail.enterprise.email}}
					</view>
				</view>
				<view v-if="invoiceDetail.invoice_type === 2" class="detail-list-item flex-center-between">
					<view class="detail-list-item-name">地址</view>
					<view class="detail-list-item-txt">
						{{invoiceDetail.enterprise.address}}
					</view>
				</view>
				
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		components: {
		},
		data() {
			return {
				invoiceDetail: {}
			}
		},
		onLoad(option) {
			this.getInvoiceDetail(option.invoiceId)
		},
		methods: {
			/**
			 * 获取详情
			 * @param {String} id
			 */
			async getInvoiceDetail(id) {
				let res = await this.$http.request({
					method: 'post',
					url: '/api/invoice/detail',
					data: { id: id }
				})
				if (res.status === 1) {
					if (res.data === '') {
						uni.showModal({
							title: '提示',
							content: '发票不存在，是否返回上一页？',
							success: function (res) {
								if (res.confirm) {
									uni.navigateBack()
								}
							}
						})
					}
					this.invoiceDetail = res.data
				} else {
					uni.showToast({
						title: res.message,
						icon: 'none',
						duration: 3000
					})
				}
			}
		}
	}
</script>

<style lang="scss">
	.invoice-detail{
		
		.detail-list{
			background: $uni-bg-color-grey;
			&-item{
				background: $uni-bg-color;
				min-height: 110rpx;
				padding: 0 50rpx;
				border-bottom: 1rpx solid $uni-border-color;
				&-name{
					color: #888888;
					font-size: 28rpx;
				}
			}
		}
	}
</style>
        